package br.com.ac.fatureweb.model.carga;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import br.com.ac.fatureweb.model.Carga;
import br.com.ac.fatureweb.utilitary.Model;

@Entity
@Table(name = "TARIFA_SOCIAL")
@SequenceGenerator(name = "SEQ_TARIFA_SOCIAL", sequenceName = "SEQ_TARIFA_SOCIAL", allocationSize = 1, initialValue = 1)
public class TarifaSocial extends Model {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6336241708293129310L;

	@Id
	@GeneratedValue(generator = "SEQ_TARIFA_SOCIAL", strategy = GenerationType.SEQUENCE)
	@Column(name = "ID")
	private Long id;

	@Column(name = "INSCRICAO")
	private Long inscricao;

	@Column(name = "CSM_MINIMO")
	private Long consumoMinimo;

	@Column(name = "COD_TARIFA_SOCIAL")
	private Long codigoTarifaSocial;

	@ManyToOne
	@JoinColumn(name = "ID_CARGA", referencedColumnName = "ID")
	private Carga carga;

	public TarifaSocial() {
		super();
	}

	public TarifaSocial(Long id, Long inscricao, Long consumoMinimo,
			Long codigoTarifaSocial, Carga carga) {
		super();
		this.id = id;
		this.inscricao = inscricao;
		this.consumoMinimo = consumoMinimo;
		this.codigoTarifaSocial = codigoTarifaSocial;
		this.carga = carga;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (!super.equals(obj)) {
			return false;
		}
		if (!(obj instanceof TarifaSocial)) {
			return false;
		}
		TarifaSocial other = (TarifaSocial) obj;
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		return true;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the inscricao
	 */
	public Long getInscricao() {
		return inscricao;
	}

	/**
	 * @param inscricao
	 *            the inscricao to set
	 */
	public void setInscricao(Long inscricao) {
		this.inscricao = inscricao;
	}

	/**
	 * @return the consumoMinimo
	 */
	public Long getConsumoMinimo() {
		return consumoMinimo;
	}

	/**
	 * @param consumoMinimo
	 *            the consumoMinimo to set
	 */
	public void setConsumoMinimo(Long consumoMinimo) {
		this.consumoMinimo = consumoMinimo;
	}

	/**
	 * @return the codigoTarifaSocial
	 */
	public Long getCodigoTarifaSocial() {
		return codigoTarifaSocial;
	}

	/**
	 * @param codigoTarifaSocial
	 *            the codigoTarifaSocial to set
	 */
	public void setCodigoTarifaSocial(Long codigoTarifaSocial) {
		this.codigoTarifaSocial = codigoTarifaSocial;
	}

	/**
	 * @return the carga
	 */
	public Carga getCarga() {
		return carga;
	}

	/**
	 * @param carga
	 *            the carga to set
	 */
	public void setCarga(Carga carga) {
		this.carga = carga;
	}

}
